package com.st.mq.topic;

import com.st.mq.constant.MqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shent
 */
@Configuration
public class TopicConfig {
    @Bean
    public Queue firstQueue() {
        return new Queue(MqConstant.TOPIC_QUEUE_MAN);
    }

    @Bean
    public Queue secondQueue() {
        return new Queue(MqConstant.TOPIC_QUEUE_WOMAN);
    }

    @Bean
    TopicExchange exchange() {
        return new TopicExchange(MqConstant.TOPIC_EXCHANGE);
    }

    @Bean
    Binding bindingExchangeMessage() {
        return BindingBuilder.bind(firstQueue()).to(exchange()).with(MqConstant.MAN);
    }

    @Bean
    Binding bindingExchangeMessageAll() {
        return BindingBuilder.bind(secondQueue()).to(exchange()).with(MqConstant.TOPIC_ALL);
    }
}
